<style lang="sass" scoped>
    .system{
        li{
            display:inline-block; 
        }  
    }
    .system li a:hover{color:#fff!important;}
    .dept-box{
        border-radius:4px;
        box-shadow:0 0 5px 0 #c1c1c1;
    }
    .dept-list{
        background: #fff;
        padding: 5px;
        position: relative;
        border: 1px solid #ddd;
        border-radius: 4px;
    }
    .dept-list:last-of-type{
        margin-bottom: 10px !important;
    }
    .choice-depart{
        position: relative;
        white-space: nowrap;
        .depart-box{
            background: #ddd;
            width:100px;
            right: -95px;
            top: 0;
            position: absolute;
            .post-box{
                cursor:pointer;
                text-align: center;
                .post-group{
                    background: red;
                    color: #fff;
                    display: none;
                    position: absolute;
                    left: 100px;
                    top: 0;
                    width: 100px;
                    text-align: center;
                }
            }
            .post-box:hover{
                .post-group{
                    display: block
                }
            }
        }
    }
    .closeBtn{
        cursor: pointer;
        position: absolute;
        right: -6px;
        top: -8px;
        border: 1px solid;
        width: 16px;
        height: 16px;
        line-height: 16px;
        text-align: center;
        font-size: 12px;
    }
    .add-dept-btn{
        width: 40px;
        height: 40px;
        line-height: 40px;
        border: 1px solid #ccc;
        display: block;
        text-align: center;
        font-size: 24px;
        color:#ccc;
        cursor:pointer;
    }
    .isChecked{
        background:#88898c;
    }

    //
    .iconfont{
        color:#ccc;
        font-size: 98px;
        border:1px solid #ccc;
        width: 100px;
        height: 100px;
        line-height: 100px;
        text-align: center;
        border-radius:50%;
    }
    .headImg{
        width: 200px;
        display: block;
        display: block;
        img{
            width: 200px;
        }
    }

</style>

<template>
<div class="container-fluid">
    <div class="row comm_conent_padding">
        <!-- 用户详情 -->
        <div class="common_block">
            <div class="head head-default">
                <i class="largeiconfont">&#xe625;</i>
                <span v-text="title"></span>
            </div>
            
            
            <div class="content pd15">
                <!-- 列表详情 -->
                <el-form  label-width="100px" class="demo-userMsg">
                    <!-- <el-form-item label="头像：" prop="bookName">
                        <div class="headLogo iconfont" v-show='userMsg.faceImg==null?true:false'>&#xe621;</div>
                        <div class="headImg" v-if='userMsg.faceImg==null?false:true'>
                            <img :src="userMsg.faceImg | sourceUrl" alt="">
                        </div>
                        <el-button type="primary" class="btn btn-primary mt10 ml20" @click='postPhoto()'>上传</el-button>
                    </el-form-item> -->
                    <el-form-item label="用户名：" prop="account">
                        <el-input v-model.trim="userMsg.account" disabled></el-input>
                    </el-form-item>
                    <el-form-item label="称呢：" prop="nickName">
                        <el-input v-model.trim="userMsg.nickName"></el-input>
                    </el-form-item>
                    <el-form-item label="密码：" prop="password">
                        <el-input v-model.trim="userMsg.password"></el-input>
                    </el-form-item>
                    <el-form-item label="邮箱：" prop="email">
                        <el-input v-model.trim="userMsg.email"></el-input>
                    </el-form-item>
                    <el-form-item label="手机：" prop="mobile">
                        <el-input v-model.trim="userMsg.mobile"></el-input>
                    </el-form-item>
                    <!-- <el-form-item label="真实姓名：" prop="userName">
                        <el-input v-model.trim="userMsg.userName"></el-input>
                    </el-form-item>
                    <el-form-item label="性别：" prop="sex">
                        <el-input v-model.trim="userMsg.sex"></el-input>
                    </el-form-item>
                    <el-form-item label="生日：" prop="deliveryTime">
                        <el-input v-model.trim="userMsg.deliveryTime"></el-input>
                    </el-form-item>
                    <el-form-item label="微信号：" prop="wxAccount">
                        <el-input v-model.trim="userMsg.wxAccount"></el-input>
                    </el-form-item>
                    <el-form-item label="QQ号：" prop="qq">
                        <el-input v-model.trim="userMsg.qq"></el-input>
                    </el-form-item> -->
                    <el-form-item>
                        <el-button @click="submitAdd()" type="primary">提交</el-button>
                    </el-form-item>
                </el-form>
            </div>        
        </div>
    </div>    
</div>
</template>

<script>
    

    export default {
        components: {
        },
        data(){
            return {
                title:this.$route.query.type=='add'?'新增用户':'修改用户', 
                type:'add',  //默认新增弹出层
                deliveryTime:'',
                //用户信息
                userMsg:{
                    account:'',
                    nickName:'',
                    password:'',
                    email:'',
                    mobile:'',

                    // birthday:null,
                    // qq:"",
                    // wxAccount:"",
                    // faceImg:null,
                    // nickName:"",
                    // sex:"",
                    // mobile:"",
                    // userName:"",
                    // account:"",
                    // email:"",
                    
                },
                //图片
            }
        },
        vuex: {
            getters: {
                
            },
            actions: {
            }
        },
        created(){
            this.getUserMsg();
        },
        mounted(){
        },
        methods: {
            //获取用户信息
            getUserMsg(){
                var This=this;
                util.ajax({
                    url:config.baseApi+'bookMall-admin/api/admin/getUpdUserInfo',
                    type:'post',
                    data:{
                        uid:This.$route.query.userId
                    },
                    success(data){
                        data.data.passoword='';
                        This.userMsg=data.data;
                        // if(This.userMsg.birthday!=''){
                        //     This.deliveryTime=new Date(This.userMsg.birthday).date('y-m-d');
                        // }                  
                        // $('#deliveryTime').daterangepicker(
                        //     {
                        //         format: 'YYYY-MM-DD',
                        //         singleDatePicker: true,
                        //         //startDate:This.userMsg.birthday,
                        //     },
                        //     function(time) {
                        //         This.userMsg.birthday = new Date(time).getTime();
                        //         This.deliveryTime = time.format('YYYY-MM-DD');
                        //     }
                        // );

                    }
                });
            },
            //上传图片
            postPhoto(){
                var This=this;
                util.cerateFileFormData({
                    url:config.baseApi+'bookMall-admin/api/tools/upload',
                    type:'post',
                    filename : "myfiles",
                    success(data){
                        This.userMsg.faceImg=data.data;
                    }
                })
            },



            // 操作用户
            submitAdd(){
                var This=this;
                var data=JSON.parse(JSON.stringify(This.userMsg));
                data['uid']=This.$route.query.userId;

                util.ajax({
                    url:config.baseApi+'bookMall-admin/api/admin/updUserInfo',
                    data:data,
                    success(data){
                        popup.miss({content:'修改成功'});
                        router.go({name:'user_list'})
                    }
                })
            },
            
        },
        
    }
</script>